package gold.digger;

import java.util.*;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC881 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int numRescueBoats(int[] people, int limit) {
            Arrays.sort(people);
            int i = 0, j = people.length - 1;
            int ans = 0;

            while (i <= j) {
                ans++;
                if (people[i] + people[j] <= limit)
                    i++;
                j--;
            }

            return ans;
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC881 an = new LC881();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
